<div class="sub_nav_box">
    <div class="sub_nav_inner">
        <div class="book-summary-opr" id="js-book-summary-opr">
            <a class="book-summary-btn"></a>    
        </div>
        <div class="top_sub_nav">
            <div class="top_title_wap">
                <span class="icon_title icon_dev"></span>
                <p class="s_title_1">开发文档</p>
            </div>
            <ul class="top_sub_list">
                <li class="sub_nav_item " data-level="1.1" data-path="../">
                    <a href="{:U('Index/index')}">
                        项目列表
                    </a>
                </li>
                <li class="sub_nav_item selected" data-level="1.1" data-path="../">
                    <a href="{:U('Doc/index')}?proid={$proid}">
                        接口列表
                    </a>
                </li>
                <if condition="($admin_user.edit_permission eq 1) or ($admin_user.type eq 0)">
                    <li class="sub_nav_item " data-level="1.1" data-path="../">
                        <a href="{:U('Doc/editApi')}?proid={$proid}">
                            添加接口
                        </a>
                    </li>
                    <li class="sub_nav_item " data-level="1.1" data-path="../">
                        <a href="{:U('Doc/typelist')}?proid={$proid}">
                            分类管理
                        </a>
                    </li>
                    <li class="sub_nav_item " data-level="1.1" data-path="../">
                        <a href="{:U('Doc/exportWord')}?proid={$proid}">
                            下载
                        </a>
                    </li>
                </if>
            </ul>
        </div>
        <!-- <h1>组件</h1> -->
        <div id="book-search-input" role="search">
            <!-- <form action='{:U("Doc/searchApi",array("proid"=>$proid))}'> -->
                <label for="search-input" class="search-icon" id="js-search-icon"></label>
                <input type="text" id="search-input" data-id="{$proid}" name="keyword" class="focus" placeholder="搜索">
                <button type="reset" class="clear-input-btn"></button>
            <!-- </form> -->
        </div>
    </div>
</div>
<script type="text/javascript">
$('#search-input').keyup(function (e) {
            if (e.keyCode == 13) {
                var now_val = $(this).val();
                //搜索接口
                // $('.ret_box').children().remove();
                var data = {proid: $(this).attr('data-id'), keyword: $(this).val()};
                $.post('{:U("Doc/searchApi")}', data, function (ret) {
                    // $(".markdown-section").hide();
                    if (ret.status != 200) {
                        PopMsg(ret.message,1,now_val);
                        // $('#search_ret').hide();
                    } else {
                        var retData = ret.show_data;
                        var html ='';
                        $(".search-results-list li").remove();
                        for (var i = 0; i < retData.length; i++) {
                            var url_href = '{:U("Doc/index")}?id=' + retData[i].id + '&proid=' + retData[i].proid;
                            var category = retData[i].t_name;
                            var title = retData[i].title;
                            html+='<li class="search-results-item">';
                            html+='                    <h3>';
                            html+='                        <a href="'+url_href+'">'+title+'</a>';
                            html+='                    </h3>';
                            html+='                    <p>'+category+'</p>';
                            html+='                </li>';
                        }
                        $(".markdown-section").hide();
                        $(".search-results-list").append(html);
                        $('.has-results .search-results-count').text(i);
                        $('.search-query').text(now_val);
                        $('.has-results').show();
                        $('.no-results').hide();
                    }
                }, 'json');
            }
        });
        /*弹框提示显示2秒后隐藏*/
    function PopMsg(content,second,keyword) {
        $('.has-results').hide();
        $('.no-results').show();
        $(".markdown-section").hide();
        // $('.has-results .search-results-count').text('0');
        $('.search-query').text(keyword);
        // $('.search-results-title').text(content);
        setTimeout(function () {
            $(".markdown-section").show();
            $('.no-results').hide();
        }, second * 1000);
    }
</script>